package com.ssyt.yt1.day7;

/**
 * 
 * 使用继承实现代码复用：<br/>
 * is a：如果要使用继承云实现代码一定要明确它们有一个明显的父子关系！
 * 
 * @author Administrator
 *
 */
class Ball {

	public String name;

}

class BasketBall extends Ball {

}

/**
 * 使用组合实现代码复用：<br/>
 * has a：这里不能使用继承，因为它们没有一个明显的父子关系，它们只一个属于关系！
 * 
 * @author Administrator
 *
 */
class Computer {

	public String brand;
	public double price;

	public Computer(String brand, double price) {
		super();
		this.brand = brand;
		this.price = price;
	}

}

class People {

	public Computer computer;

	public People(Computer computer) {
		this.computer = computer;
	}
}

/**
 * 使用继承还是使用组合？
 * 
 * @author Administrator
 *
 */
public class InheritanceChoice {

	public static void main(String[] args) {
		People people = new People(new Computer("Lenovo", 888888.88));
		System.out.println(people.computer.brand);
	}
}
